//
//  BaseVC.m
//  ZhiXingStore
//
//  Created by Cocoa on 2019/3/6.
//  Copyright © 2019年 QiaoLiKeJi. All rights reserved.
//

#import "BaseVC.h"


@interface BaseVC ()


@end

@implementation BaseVC

-(void)loadView {
    self.pContentView = [[YBBaseView alloc] initWithFrame:ScreenBounds];
    self.pContentView.backgroundColor = global_viewBackgroundColor;
    self.view = self.pContentView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
//    self.view.backgroundColor = UIColor.clearColor;
//    self.pContentView = [[YBBaseView alloc] initWithFrame:ScreenBounds];
//    self.pContentView.backgroundColor = global_viewBackgroundColor;
//    [self.view addSubview:self.pContentView];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}


#pragma mark action
- (void)handleRightItemAction{}
- (void)handleBackItemAction{
    if (self.navigationController.viewControllers.count > 1)
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
    else
    {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}
- (void)setLeftTitle:(NSString *)leftTitle {
    _leftTitle = leftTitle;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.leftBtn];
    [self.leftBtn setTitle:leftTitle forState:UIControlStateNormal];
    [self.leftBtn setTitle:leftTitle forState:UIControlStateHighlighted];
}

- (void)setRightTitle:(NSString *)rightTitle{
    _rightTitle = rightTitle;
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.rightButton];
    [self.rightButton setTitle:rightTitle forState:UIControlStateNormal];
    [self.rightButton setTitle:rightTitle forState:UIControlStateHighlighted];
//    [self.rightButton setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    [self.rightButton setImage:[UIImage imageNamed:@""] forState:UIControlStateHighlighted];
    
}

- (void)setRightImageStr:(NSString *)rightImageStr{
    _rightImageStr = rightImageStr;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.rightButton];
    [self.rightButton setImage:[UIImage imageNamed:rightImageStr] forState:UIControlStateNormal];
    [self.rightButton setImage:[UIImage imageNamed:rightImageStr] forState:UIControlStateHighlighted];
//    [self.rightButton setTitle:@"" forState:UIControlStateNormal];
//    [self.rightButton setTitle:@"" forState:UIControlStateHighlighted];
}

- (UIButton *)rightButton{
    if (!_rightButton) {
        _rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _rightButton.frame = CGRectMake(0, 0, 48, 44);
        _rightButton.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, -10);
        _rightButton.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, -8);
//        [_rightButton setTitleColor:UIColor.k_hexColor(0xFFCE00) forState:UIControlStateNormal];
//        [_rightButton setTitleColor:UIColor.k_hexColor(0xFFCE00) forState:UIControlStateHighlighted];
        _rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
        [_rightButton addTarget:self action:@selector(handleRightItemAction) forControlEvents:UIControlEventTouchUpInside];
        _rightButton.hidden = NO;
        _rightButton.tintColor = UIColor.whiteColor;
    }
    return _rightButton;
}
- (UIButton *)leftBtn{
    if (!_leftBtn) {
        _leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _leftBtn.frame = CGRectMake(0, 0, 48, 44);
        _leftBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, -10);
        _leftBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, -8);
        //        [_rightButton setTitleColor:UIColor.k_hexColor(0xFFCE00) forState:UIControlStateNormal];
        //        [_rightButton setTitleColor:UIColor.k_hexColor(0xFFCE00) forState:UIControlStateHighlighted];
        _leftBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_leftBtn addTarget:self action:@selector(handleBackItemAction) forControlEvents:UIControlEventTouchUpInside];
        _leftBtn.hidden = NO;
        _leftBtn.tintColor = UIColor.whiteColor;
    }
    return _leftBtn;
}

@end
